<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>账号信息</title>
    <link rel="stylesheet" href="../res/layui/css/layui.css">
    <style>
        body {
            font-family: "Microsoft YaHei", Arial, sans-serif;
            margin: 0;
            padding: 20px;
        }
    </style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header">账号信息</div>
        <div class="layui-card-body">
            <form class="layui-form" lay-filter="adminInfoForm">
                <div class="layui-form-item">
                    <label class="layui-form-label">用户名</label>
                    <div class="layui-input-block">
                        <input type="text" id="username" class="layui-input" readonly>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">账号</label>
                    <div class="layui-input-block">
                        <input type="text" id="account" class="layui-input" readonly>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">创建时间</label>
                    <div class="layui-input-block">
                        <input type="text" id="createTime" class="layui-input" readonly>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">角色</label>
                    <div class="layui-input-block">
                        <input type="text" id="role" class="layui-input" readonly value="管理员">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">登录时间</label>
                    <div class="layui-input-block">
                        <input type="text" id="loginTime" class="layui-input" readonly>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="../res/layui/layui.js"></script>
<script>
    layui.use(['form', 'layer', 'jquery'], function() {
        var form = layui.form;
        var layer = layui.layer;
        var $ = layui.jquery;
        
        // 获取当前登录用户信息
        $.ajax({
            type: 'get',
            url: '/admin/getInfo',
            dataType: 'json',
            success: function(resp) {
                if (resp.code === 0 && resp.data) {
                    // 填充账号信息
                    $('#username').val(resp.data.username || $('#loginName').text() || '管理员');
                    $('#account').val(resp.data.account || $('#loginName').text() || 'admin');
                    $('#createTime').val(resp.data.createTime ? layui.util.toDateString(resp.data.createTime, 'yyyy-MM-dd HH:mm:ss') : '未知');
                    $('#role').val(resp.data.role || '管理员');
                    $('#loginTime').val(resp.data.loginTime ? layui.util.toDateString(resp.data.loginTime, 'yyyy-MM-dd HH:mm:ss') : '未知');
                } else {
                    // 如果获取失败，使用默认信息
                    $('#username').val($('#loginName').text() || '管理员');
                    $('#account').val($('#loginName').text() || 'admin');
                    $('#createTime').val('未知');
                    $('#loginTime').val('未知');
                }
            },
            error: function() {
                // 请求失败时使用默认信息
                $('#username').val($('#loginName').text() || '管理员');
                $('#account').val($('#loginName').text() || 'admin');
                $('#createTime').val('未知');
                $('#loginTime').val('未知');
            }
        });
    });
</script>
</body>
</html>